package com.csproj.siiat.aop.logging;

import com.csproj.siiat.base.common.dto.BaseDTO;
import com.csproj.siiat.base.common.logback.Logback;
import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.core.env.Environment;

/**
 * Aspect for logging execution of service and repository Spring components.
 *
 * By default, it only runs with the "dev" profile.
 */
@Aspect
public class RequestResultAspect {
    private final Logger log = LoggerFactory.getLogger(this.getClass());

    private final Environment env;

    public RequestResultAspect(Environment env){
        this.env = env;
    }


    /**
     * Pointcut that matches all Spring beans in the application's main packages.
     */
    @Pointcut("within(com.csproj.basic.resource.*)"+
            " || within(com.csproj.dispatch.resource.*)"+
            " || within(com..csproj.system.resource.*)")
    public void applicationPackagePointcut() {
        // Method is empty as this is just a Pointcut, the implementations are in the advices.
    }

    /**
     * 切点之前的操作
     *
     * @param rvt
     */
   @Around("within(com.csproj.basic.resource.*)"+
           " || within(com.csproj.dispatch.resource.*)"+
           " || within(com..csproj.system.resource.*)")
   public Object ReturnAfter(ProceedingJoinPoint pjp) throws Throwable
   {
            return pjp.proceed();
//       Object obj = pjp.proceed();
//       System.out.println("----"+obj.toString());
//       return  BaseDTO.createBaseDTO().setData(obj);

   }

}
